package com.note.simpleshop.utils;

import java.lang.reflect.Field;
import java.sql.ResultSet;

/***
 *@ClaseName:ClassUtils
 *
 *@Decription:
 *
 *@Author: xubingbing
 *
 *@Date:2019/3/10 0010 22:45
 */
public class ClassUtils {
    public static Object getInstance(Class tClass, ResultSet resultSet) {
        try {
            Object object = Class.forName(tClass.getName()).newInstance();
            Class<?> obj = object.getClass();
            Field[] fields = obj.getDeclaredFields();
            for (int i = 0; i < fields.length; i++) {
                fields[i].setAccessible(true);
                fields[i].set(object,resultSet.getObject(fields[i].getName()));
            }
            return object;
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
